import tool from './tool'
const managerTool = {
  guid () {
    let tempstr = 'xxxxxxxxxxxx4xxxyxxxxxxxxxxxxxxx'.replace(/[xy]/g, function (
      c
    ) {
      let r = (Math.random() * 16) | 0,
        v = c == 'x' ? r : (r & 0x3) | 0x8
      return v.toString(16)
    })
    let result = tempstr.substring(tempstr.length - 13, tempstr.length) + new Date().getTime()
    return result
  },
  // 验证：正、负 、小数
  validationNum (val) {
    let regu = /^(\-|\+)?\d+(\.\d+)?$/
    if (val != '') {
      if (!regu.test(val)) {
        return false
      } else {
        return true
      }
    }
    return false
  },
  validationUrl (val) {
    let regu = /^(http|https)?:\/\//
    if (val != '') {
      if (!regu.test(val)) {
        return false
      } else {
        return true
      }
    }
    return true
  },
  // 验证：正、小数
  validationPositiveNum (val) {
    let regu = /^(\+)?\d+(\.\d+)?$/
    if (val != '') {
      if (!regu.test(val)) {
        return false
      } else {
        return true
      }
    }
    return false
  }
}
export default managerTool